Component({
  properties: {
    text: String,
    duration: {
      type: Number,
      value: 1500
    },
    mask: Boolean
  },
  data: {
    visible: false,
    timer: null
  },
  methods: {
    show() {
      const { duration } = this.data
      
      this.setData({ visible: true })
      
      if (this.data.timer) {
        clearTimeout(this.data.timer)
      }
      
      if (duration > 0) {
        const timer = setTimeout(() => {
          this.hide()
        }, duration)
        
        this.setData({ timer })
      }
    },
    
    hide() {
      this.setData({ visible: false })
    }
  }
})